#ifndef __QE_DRIVER_H__
#define __QE_DRIVER_H__



#include "qe_device.h"

#include "qe_cache.h"



#if defined(CONFIG_DMA)
#include "qe_dmaengine.h"
#endif

#if defined(CONFIG_INTERRUPT)
#include "qe_interrupt.h"
#endif

#if defined(CONFIG_GPIO)
#include "qe_gpio.h"
#endif

#if defined(CONFIG_I2C)
#include "qe_i2c.h"
#endif

#if defined(CONFIG_SERIAL)
#include "qe_serial.h"
#if defined(CONFIG_EARLYCON)
#include "qe_earlycon.h"
#endif
#endif

#if defined(CONFIG_SPI)
#include "qe_spi.h"
#if defined(CONFIG_SPI_FLASH)
#include "qe_spi_flash.h"
#endif
#endif

#if defined(CONFIG_I2C)
#include "qe_i2c.h"
#endif

#if defined(CONFIG_TIMER)
#include "qe_timer.h"
#endif

#if defined(CONFIG_HWBOOT)
#include "qe_hwboot.h"
#endif

#define QE_DRIVER_START(_name)\
    const qe_driver qe_driver_list_##_name \
    __attribute__((used)) qe_section(".qe_driver_list.0")

#define QE_DRIVER_END(_name)\
    const qe_driver qe_driver_list_##_name \
    __attribute__((used)) qe_section(".qe_driver_list.2.end")

#define QE_DRIVER(_name) \
    const qe_driver qe_driver_list_##_name \
    __attribute__((used)) qe_section(".qe_driver_list.1") \

#define QE_DRIVER_FORCE_EXPORT(_name) \
    void _name##_driver_force_include(void) { \
        (void)&qe_driver_list_##_name; \
    };

#define QE_DRIVER_FORCE_IMPORT(_name) \
    extern void _name##_driver_force_include(void); \
    _name##_driver_force_include();

typedef struct
{
    char *name;
    const qe_device_id *of_match;
    qe_ret (*probe)(const void *fdt, int offset);
    qe_ret (*probex)();
} qe_driver;


void qe_dm_scan(const void *fdt);

void qe_driver_force_include(void);



#endif /* __QE_DRIVER_H__ */